#include "BaseLayer.h"
#include "Resources.h"
#include "VisibleRect.h"

bool BaseLayer::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!CCLayer::init());
		setKeypadEnabled(true);
		bRet = true;
	} while (0);
	return bRet;
}
void BaseLayer::addBg(int bg)
{
	CCTexture2D *pT = CCTextureCache::sharedTextureCache()->textureForKey(s_bg);
	CCRect *pRect = NULL;
	if (kBG1 == bg)
	{
		//rect = CCRectMake(0, 412, 618, 412);
		pRect = new CCRect(0, 412, 618, 412);
	} else if (kBG2 == bg)
	{
		//rect = CCRectMake(0, 0,618, 412);
		pRect = new CCRect(0, 0, 618, 412);
	}
	CCSprite *pBg = CCSprite::createWithTexture(pT, *pRect);
	pRect->release();
	CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
	float scale = screenSize.width / pBg->getContentSize().width;
	pBg->setScale(scale);
	pBg->setPosition(VisibleRect::center());
	this->addChild(pBg);
}